/* $Header: config.h,v 2.3 02/01/22 12:47:31 przybyls Exp $ */

/***********************************************************************/
/* INCLUDE FILE NAME:  config.h                                        */
/* ==================                                                  */
/*                                                                     */
/* Author:  Tom Przybylski                                             */
/*                                                                     */
/* COMMENT: This file defines the structures of configuration and      */
/*          calibration data.                                          */
/*                                                                     */
/*                                                                     */
/*                                                                     */
/***********************************************************************/

#ifndef CONFG_H
#define CONFG_H

/*****************************/
/*   IFDEFS                  */
/*****************************/


/*****************************/
/*   SYMBOLIC CONSTANTS      */
/*****************************/


#define  NMBR_MAILBOXES   4       /* number of host mailboxes */
#define  MAILBOX_SIZE    64      /* size (in bytes) of each mailbox */

/*****************************/
/*   MACROS                  */
/*****************************/


/*****************************/
/*   TYPEDEFS                */
/*****************************/

typedef enum {    ENGLISH    = 0,
                  GERMAN     = 1,
                  SPANISH    = 2,
                  FRENCH     = 3,
                  ITALIAN    = 4
             } LANGUAGE;



/* Detector type decoding for DSP */
typedef enum
{
        NULL_DETECTOR   = 0x00,         /* No detector installed type */
        SQRT_DETECTOR   = 0x01,         /* FID type detector (sq root)*/
        TCD_DETECTOR    = 0x02,         /* TCD installed              */
        LINEAR_DETECTOR = 0x03,         /* Linear detector installed  */
                                        /*  (e.g. AIB, FPD, ECD)      */
        OTHER_DETECTOR  = 0x04          /* Other type detector        */
                                        /*  (treated as linear)       */
} DSP_DET_TYPE;

typedef struct
{
        DSP_DET_TYPE    type;
        U_INT32         offset;
        U_INT32         offset_sum;
        U_INT16         offset_count;
} DET_REC;

/* RS232 Configuration */
typedef enum
{
   BR_300,
   BR_1200,
   BR_2400,
   BR_4800,
   BR_9600,
   BR_19200,
   BR_28800,
   BR_38400,
   BR_57600,
   BR_115200,
   BR_230400

} BAUD_RATE_TYPE;

typedef enum
{
   HS_NONE,            /* no handshake */
   HS_DUART_HW,        /* handshake handled by duart (specific to 2692) */
   HS_XON_XOFF,        /* XON and XOFF in both directions   */
   HS_HARDWARE         /* CTS and RTS handshake in both directions */
} HANDSHAKE_TYPE;

typedef enum
{
   PARITY_NONE,       /* no parity bit on receive or transmit */
   PARITY_ODD,        /* check and send odd parity */
   PARITY_EVEN,       /* check and send even parity */
   PARITY_MARK,       /* check and send parity bit as 1 */
   PARITY_SPACE       /* check and send parity bit as 0 */
} PARITY_TYPE;

typedef enum
{
   STOP_BITS_1,       /* number of stop bits sent per char */
   STOP_BITS_1_5,
   STOP_BITS_2
} STOP_BITS_TYPE;

typedef enum
{
   DATA_BITS_7,       /* number of bits per char */
   DATA_BITS_8
} DATA_BITS_TYPE;

typedef enum
{
   TERM_SEQ_LF,       /* terminating sequence = Line Feed */
   TERM_SEQ_CR        /* terminating sequence = Carriage Return */
} TERM_SEQ_TYPE;

typedef struct
{
      BAUD_RATE_TYPE     Baud_Rate;
      HANDSHAKE_TYPE     Handshake;
      PARITY_TYPE        Parity;
      STOP_BITS_TYPE     Stop_Bits;
      DATA_BITS_TYPE     Data_Bits;
      TERM_SEQ_TYPE      Term_Seq;
} SERIAL_PARMS_TYPE;

/* host datacomm data format  */
typedef enum
{
      BIN,          /* binary format */
      HEX,          /* binary format msg converted to hexadecimal */
      DEC,          /* decimal format */
      CMP           /* send data in compressed hex format */
}  DATA_FORMAT_TYPE;


/* host datacomm data acquistion mode  */
typedef enum
{
      CON,         /* acq unrelated to run machine, controlled by cmds */
      RUN,         /* start acq at start of run and stop at end of run */
      SGL          /* reset buf & start acq at start of run and  */
                   /*      stop at end of run */
}   ACQ_MODE_TYPE;

/* Host mailboxes */
typedef struct
{
   BIT8  time[6];
   BIT8  date[6];
   BIT8  msg_len;
   BIT8  message[MAILBOX_SIZE];
}  HOST_MAILBOX_TYPE;




typedef struct
{
   BIT8    version;
   U_INT8  update;
   U_INT8  fix;
} REV_CODE;


/*****************************/
/*   EXTERNALS               */
/*****************************/

#pragma SECTION DATA=pfail

/* revisit: used to support fake configs entered from keyboard (rick) */
extern  BIT8           Dont_Use_Real_Configuration;
extern  BIT8           Hacksaw;

extern  ON_OFF         Auto_Prep_Run;

extern  BIT8           Radix_Char;
extern  BIT8           KeyClickEnabled;
extern  BIT8           WarningBeepEnabled;
extern  LANGUAGE       Language;
extern  BIT8           Keyboard_Lock;
extern  BIT8           SetptBeepEnabled;    /* REVISIT: FOR TEST ONLY? */

#define STATUS_SIZE    15
extern  INT8           Status[STATUS_SIZE];

extern  REV_CODE       Version;


/* Digital Data Configuration for SIGNAL1 and SIGNAL2 */
   extern   DATA_FORMAT_TYPE  Data_Format[];    /* data format for host  */
   extern   ACQ_MODE_TYPE     Acq_Mode[];       /* data acquistion mode  */

/* RS232 Configuration (saved copy for initialization) */
   extern   SERIAL_PARMS_TYPE Init_Host_Port_Serial_Parms;

extern const SERIAL_PARMS_TYPE Default_Host_Port_Serial_Parms;
extern const SERIAL_PARMS_TYPE On_Board_Computer_Serial_Parms;
extern const SERIAL_PARMS_TYPE Tower_Port_Parms;
extern const SERIAL_PARMS_TYPE Tray_Port_Parms;
extern const SERIAL_PARMS_TYPE Headspace_Port_Parms;

/* Host Mailboxes */
   extern HOST_MAILBOX_TYPE Mailbox[NMBR_MAILBOXES];


/* Valve Configuration      */
   extern    VALVE_CONFIG     Valve_Configs[8];
   extern    U_INT32          Multi_Time;          /* Switching time of multi valve */
   extern    BIT8             Negative_Logic;      /* 1's compliment BCD if TRUE    */

extern  DET_REC         DetectorA;          /* detector type & offset used by signal DSP */
extern  DET_REC         DetectorB;

extern  ON_OFF          PE_Defect_Fix;      /* Control for 0xINJ_CONFIG response */

#pragma SECTION UNDO

extern  BIT8            Valve_Box_Config;  /* Image of the 4 valve config bits*/
extern  U_INT8          Multi_Valve;       /* Valve# of multiposition valve   */
extern  U_INT8          Remote_Start_Valve;/* Valve# of remote start valve    */
extern  U_INT8          Gsv1;              /* Valve# of 1st GSV               */
extern  U_INT8          Gsv2;              /* Valve# of 2nd GSV               */

extern  BIT8            Sequence_Lock;
extern  BIT8            DC_Keyboard_Lock;
extern  BIT8            LSMSeq_Lock;       /* Load/Store/Method/Clock Tbl/Sequence lock */
extern  BIT8            Clock_Tbl_Lock;
extern  BIT8            CT_Execute_Lock;

#endif
